package com.example.camera;

import android.annotation.SuppressLint;
import android.graphics.Bitmap;
import android.os.Parcel;
import android.os.Parcelable;

import java.text.SimpleDateFormat;
import java.util.Date;


class PhotoInfo implements Parcelable {
    private Bitmap image;
    private String time;
    private double latitude;
    private double longitude;


    public PhotoInfo(Bitmap image, String time, double latitude, double longitude) {
        this.image = image;
        this.time = time;
        this.latitude = latitude;
        this.longitude = longitude;
    }


    public PhotoInfo(Parcel in) {
        this.image = in.readParcelable(Bitmap.class.getClassLoader());
        this.time = in.readString();
        this.latitude = in.readDouble();
        this.longitude = in.readDouble();
    }


    public Bitmap getImage() {
        return image;
    }

    public String getTime() {
        return time;
    }

    public double getLatitude() {
        return latitude;
    }

    public double getLongitude() {
        return longitude;
    }


    @Override
    public int describeContents() {
        return 0;
    }


    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(image, flags);
        dest.writeString(time);
        dest.writeDouble(latitude);
        dest.writeDouble(longitude);
    }


    public static final Parcelable.Creator<PhotoInfo> CREATOR = new Parcelable.Creator<PhotoInfo>() {

        @Override
        public PhotoInfo createFromParcel(Parcel source) {
            return new PhotoInfo(source);
        }


        @Override
        public PhotoInfo[] newArray(int size) {
            return new PhotoInfo[size];
        }
    };

    public String getFormattedTime() {

        @SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        Date date = new Date(Long.parseLong(this.time) * 1000);

        return formatter.format(date);
    }

}